package UnitTest.AlgorithmTest.combineTest.sumofSubSequenceTest.LMSTest;

import Algorithm.comprehensive.sumofSubSequence.LMS.LargestMultiofSubSequence;
import org.junit.Test;

/**
 * @author liujun
 * @version 1.0
 * @date 2021/1/27
 * @author—Email liujunfirst@outlook.com
 * @blogURL https://blog.csdn.net/ljfirst
 * @description 最大子段乘积(连续)
 * 给定一个数组，求出这个数组最大连续的子段乘积
 * 输入：{5, -4, 3, 4, 9}
 * 输出：3 * 4 * 9 = 108
 */
public class LargestMultiofSubSequenceTest {

    LargestMultiofSubSequence largestMultiofSubSequence = new LargestMultiofSubSequence();

    @Test
    public void test() {
        int target = largestMultiofSubSequence.calculate(demo01);
        assert target == 108;
        target = largestMultiofSubSequence.calculate(demo02);
        assert target == 2160;
        target = largestMultiofSubSequence.calculate(demo03);
        assert target == 2160;
        target = largestMultiofSubSequence.calculate(demo031);
        assert target == 2160;
        target = largestMultiofSubSequence.calculate(demo032);
        assert target == 108;
        target = largestMultiofSubSequence.calculate(demo04);
        assert target == 432;
        target = largestMultiofSubSequence.calculate(demo05);
        assert target == 933120;
        target = largestMultiofSubSequence.calculate(demo06);
        assert target == 448;
        target = largestMultiofSubSequence.calculate(demo07);
        assert target == 17640;
        target = largestMultiofSubSequence.calculate(demo08);
        assert target == 576;
    }

    int[] demo01 = {5, -4, 3, 4, 9};   //108
    int[] demo02 = {5, 4, 3, 4, 9};    //2160
    int[] demo03 = {5, -4, 3, -4, 9};  //2160
    int[] demo031 = {5, 1, -4, 3, -4, 9};  //2160
    int[] demo032 = {5, 1, -4, -3, -4, 9};  //108
    int[] demo04 = {-5, -4, 3, -4, 9}; //432
    int[] demo05 = {-5, -4, 3, -4, 9, 5, -4, 3, -4, 9};//933120
    int[] demo06 = {2, 7, 6, -5, 8, 7, 8};//448
    int[] demo07 = {4, -2, -7, -5, 8, -7, 1, -9};//17640
    int[] demo08 = {1, 2, 3, 4, -9, 3, 4, 6, 8};//576
}
